<template>
    <div class="row">
        <div class="col-xs-12 col-md-12">
            <ms-dialog :widget="{$innerVm: 'demo_form', show: @show, onOk: @handleOk, title: @isEdit ? '修改' : '新增', onCancel: function () { @show = false; }}">
                <div slot="body" ms-skip>
                    <xmp is="ms-form" :widget="{$form: @$form}">
                        <ms-form-item :widget="{label: 'ID'}">
                            <ms-input :widget="{value:@record.region_id,col: 'region_id', $rules: { required: true, message: '地区ID不能为空' }}"></ms-input>
                        </ms-form-item>
                        <ms-form-item :widget="{label: '名称'}">
                            <ms-input :widget="{value:@record.region_name,col: 'region_name', $rules: { required: true, message: '地区名称不能为空' }}"></ms-input>
                        </ms-form-item>
                        <ms-form-item :widget="{label: 'PID'}">
                            <ms-input :widget="{value:@record.region_parent_id,col: 'region_parent_id', $rules: { required: true, message: '地区PID不能为空' }}"></ms-input>
                        </ms-form-item>
                        <ms-form-item :widget="{label: '套餐'}" :for="($index, el) in @record.suites">
                            <ms-input :widget="{value:el.name,col: 'suites[' + $index + '].name'}"></ms-input>
                        </ms-form-item>
                    </xmp>
                </div>
            </ms-dialog>
            <ms-form :widget="{$form:@$searchForm,type:'search',inline:true}">
                <div class="row">
                    <div class="col-md-2">
                        <ms-form-item :widget="{label: 'ID：'}">
                            <ms-input :widget="{col: 'region_id', width: '75%'}"></ms-input>
                        </ms-form-item>
                    </div>
                    <div class="col-md-2">
                        <ms-form-item :widget="{label: '名称：'}">
                            <ms-input :widget="{col: 'region_name.firstName', width: '75%'}"></ms-input>
                        </ms-form-item>
                    </div>
                    <div class="col-md-3">
                        <ms-form-item :widget="{label: '开始日期：'}">
                            <ms-datepicker :widget="{
                                col:'startDate',
                                placeholder:'请选择开始日期',
                                width: '70%'
                            }"></ms-datepicker>
                        </ms-form-item>
                    </div>
                    <div class="col-md-3">
                        <ms-form-item :widget="{label: '结束日期：'}">
                            <ms-datepicker :widget="{
                                col:'endDate',
                                placeholder:'请选择结束日期',
                                width: '70%'
                            }"></ms-datepicker>
                        </ms-form-item>
                    </div>
                    <div class="col-md-2">
                        <button type="button" class="btn btn-primary" :click="@search">
                            <span class="fa fa-search"></span>搜索
                        </button>
                        <button type="button" class="btn btn-success pull-right" :click="actions('add')">
                            <span class="fa fa-plus">
                            </span>新增地区
                        </button>
                    </div>
                </div>
            </ms-form>
            <ms-table :widget="{data:@list,actions:@actions,pagination:@pagination,onChange:@handleTableChange}">
                <ms-table-header :widget="{dataIndex:'region_id',type:'selection'}"></ms-table-header>
                <ms-table-header :widget="{title:'地区',dataIndex:'region_name'}"></ms-table-header>
                <ms-table-header :widget="{title:'PID',dataIndex:'region_parent_id'}"></ms-table-header>
                <ms-table-header :widget="{title:'操作',dataIndex:'region_id'}">
                    <button type="button" class="btn btn-default btn-xs" :click="handle('edit')"><i class="fa fa-edit"></i> 编辑</button>
                    <button type="button" class="btn btn-danger btn-xs" :click="handle('delete')"><i class="fa fa-trash-o"></i> 删除</button>
                </ms-table-header>
            </ms-table>
        </div>
    </div>
</template>